<template>
    <div class="page">
        <tabs :options="tabs" v-model="tabsActive" @onclick="handleTabClick"/>
        <router-view ref="ref-router-view"/>
    </div>
</template>

<style lang="less" scoped>
    .page{
        .search-view{
            /*margin-top: 4.3rem;*/
        }
        .swiper-box{
            margin: .9rem;
        }

    }
</style>

<script>
    export default {
        data(){
            let tabsActive = 0;
            const type = this.$route.params.type;
            if(type){
                tabsActive = parseInt(type.match(/\d+$/));
            }
            return {
                tabs: ['全部资讯', '政策法规', '每日早餐', '业界动态', '研究分析', '交易日历', '好文推荐'],
                tabsActive,
            }
        },
        methods: {
            handleTabClick(key){
                if(key == 0){
                    this.$router.replace('/study');
                }else{
                    this.$router.replace('/study/type/type' + key);
                }

            },

            onNavEvent(key){
                const ref = this.$refs['ref-router-view'];
                ref && ref.onNavEvent && ref.onNavEvent(key);
            }
        }
    }
</script>